package com.example.project.projectspringcloud.controller.admin;

import com.example.project.projectspringcloud.common.log.LoggerManage;
import com.example.project.projectspringcloud.service.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Api(tags = "后台admin控制器")
@Controller
@RequestMapping(value = "/admin")
public class AdminIndexController {

    @Autowired
    private StatisticsService statisticsService;

    @LoggerManage(description = "返回admin首页")
    @ApiOperation(value = "admin首页", notes = "返回admin首页")
    @GetMapping(value = {"", "/index"})
    public String index() throws Exception {

        return "admin/index";
    }

    @LoggerManage(description = "返回admin首页内嵌欢迎页面")
    @ApiOperation(value = "admin首页内嵌欢迎页面", notes = "返回admin首页内嵌欢迎页面")
    @GetMapping(value = "/welcome")
    public String welcome(Model model) throws Exception {
        model.addAttribute("statistics", statisticsService.someCount());
        return "admin/welcome";
    }
}
